package cn.geekyspace.scanhive.application.dto.query;

import cn.geekyspace.scanhive.domain.entity.CleaningData;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 扫描记录分页查询
 */
@Data
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class QueryData extends Page<CleaningData> {

    @Serial
    private static final long serialVersionUID = 6791971141685985830L;

    private Integer id;
    // 条码
    private String qrCode;
    //清洗
    private Integer cleaningDuration;    // 时长（单位：秒）
    private Double cleaningTemperature;  // 温度（单位：℃）
    //漂洗
    private Integer rinsingDuration;     // 时长（单位：秒）
    private Double rinsingTemperature;   // 温度（单位：℃）
    //烘干
    private Integer dryingDuration;      // 时长（单位：秒）
    private Double dryingTemperature;    // 温度（单位：℃）
    // 条码扫码时间
    private LocalDateTime qrCodeScanTimeStart;
    private LocalDateTime qrCodeScanTimeEnd;

    public QueryData setQrCodeScanTimeStart(LocalDate qrCodeScanTimeStart) {
        if (qrCodeScanTimeStart != null) {
            this.qrCodeScanTimeStart = qrCodeScanTimeStart.atStartOfDay();
        }
        return this;
    }

    public QueryData setQrCodeScanTimeEnd(LocalDate qrCodeScanTimeEnd) {
        if (qrCodeScanTimeEnd != null) {
            this.qrCodeScanTimeEnd = qrCodeScanTimeEnd.atStartOfDay().plusDays(1).minusSeconds(1);
        }
        return this;
    }

    // PLC数据回传时间
    private LocalDateTime plcDataReturnTime;

}
